import 'package:flutter_pickers/more_pickers/route/single_picker_route.dart';
import 'package:flutter_pickers/pickers.dart';
import 'package:flutter_pickers/style/picker_style.dart';
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
import 'package:flutter_pickers/time_picker/model/pduration.dart';
import 'package:flutter_pickers/time_picker/route/date_picker_route.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';

class HLPicker {
  /*
  * 弹框
  * */
  static void showPicker({
    required List<String> data,
    String? selectData,
    SingleCallback? onConfirm,
    Function(bool isCancel)? onCancel,
    bool overlapTabBar = false,
  }) {
    Pickers.showSinglePicker(Get.context!,
        data: data,
        selectData: selectData,
        overlapTabBar: overlapTabBar,
        onConfirm: onConfirm,
        onCancel: onCancel,
        pickerStyle: PickerStyle(
            headDecoration: const BoxDecoration(color: Color.fromRGBO(240, 234, 230, 1.0)),
            textColor: Colors.black,
            textSize: 22,
            pickerHeight: 240,
            pickerItemHeight: 50,
            pickerTitleHeight: 50,
            cancelButton: Padding(
                child: Text(
                  "取消",
                  style: TextStyle(
                    color: Colors.black54,
                    fontSize: 16,
                    fontWeight: FontWeight.bold,
                  ),
                ),
                padding: EdgeInsets.only(left: 16)),
            commitButton: Padding(
                child: Text(
                  "确认",
                  style: TextStyle(
                    color: Colors.blueAccent,
                    fontSize: 16,
                    fontWeight: FontWeight.bold,
                  ),
                ),
                padding: EdgeInsets.only(right: 16))));
  }

/*
* 时间弹框
* */
  static void showDatePicker({
    DateMode mode = DateMode.YMD,
    PDuration? selectDate,
    PDuration? maxDate,
    PDuration? minDate,
    DateCallback? onChanged,
    DateCallback? onConfirm,
    Function(bool isCancel)? onCancel,
    bool overlapTabBar = false,
  }) {
    Pickers.showDatePicker(
      Get.context!,
      mode: mode,
      selectDate: selectDate,
      maxDate: maxDate,
      minDate: minDate,
      onConfirm: onConfirm,
      onCancel: onCancel,
      onChanged: onChanged,
      overlapTabBar: overlapTabBar,
      pickerStyle: PickerStyle(
        headDecoration: const BoxDecoration(color: Color.fromRGBO(240, 234, 230, 1.0)),
        textColor: Colors.black,
        textSize: 22,
        pickerHeight: 240,
        pickerItemHeight: 50,
        pickerTitleHeight: 50,
        cancelButton: Padding(
          child: Text(
            "取消",
            style: TextStyle(
              color: Colors.black54,
              fontSize: 16,
              fontWeight: FontWeight.bold,
            ),
          ),
          padding: EdgeInsets.only(left: 16),
        ),
        commitButton: Padding(
            child: Text(
              "确认",
              style: TextStyle(
                color: Colors.blueAccent,
                fontSize: 16,
                fontWeight: FontWeight.bold,
              ),
            ),
            padding: EdgeInsets.only(right: 16)),
      ),
    );
  }
}
